package com.windoent.yugioh.adapter.brvah;

import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.module.LoadMoreModule;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.windoent.yugioh.R;
import com.windoent.yugioh.bean.CaiPanListSearchData;
import com.windoent.yugioh.utils.BaseMethod;
import com.windoent.yugioh.utils.SimpleUtils;
import com.windoent.yugioh.widget.RoundImageView;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
 * @author: limuyang
 * @date: 2019-12-04
 * @Description:
 */
public class SearchBaomingJudgeAdapter extends BaseQuickAdapter<CaiPanListSearchData.DataBean.MergeRefereeBean, BaseViewHolder> implements LoadMoreModule {

    public SearchBaomingJudgeAdapter() {
        super(R.layout.layout_animation);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder helper, @Nullable CaiPanListSearchData.DataBean.MergeRefereeBean item) {

        helper.setText(R.id.tv_name, BaseMethod.notNullDefaultValueNull(item.getNickname()))
                .setText(R.id.tv_id, getContext().getString(R.string.string_user_info_id) + BaseMethod.notNullDefaultValueNull(item.getRefereeViewId() + ""));
        RoundImageView imageView = helper.getView(R.id.image);
        SimpleUtils.loadImageForView(getContext(), imageView, item.getAvatar(), R.drawable.img_official_avatar_android);
        int statusId = item.getStatusId();
        TextView tv_button = helper.getView(R.id.tv_button);
        setText(tv_button, statusId);
    }

    private void setText(TextView textView, int status) {
        if (status == 1) {
            //去通过
            textView.setSelected(false);
            textView.setText(getContext().getString(R.string.string_baoming_auth_caipan_pass_games));
        } else if (status == 2) {
            //去退赛
            textView.setSelected(true);
            textView.setText(getContext().getString(R.string.string_baoming_auth_caipan_exit_games));
        }
    }
}
